package com.wq.babysecretary.presenter;


import com.wq.babysecretary.base.RxPresenter;
import com.wq.babysecretary.model.BaBayStoryModel;
import com.wq.babysecretary.model.impi.WebBookModelImpl;
import com.wq.babysecretary.presenter.contract.BabyStoryContract;
import com.wq.babysecretary.weight.SimpleObserver;

import java.util.List;

import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by wq
 */

public class BaByStoryPresenter extends RxPresenter<BabyStoryContract.View>
        implements BabyStoryContract.Presenter {

    @Override
    public void loadBillboardList() {

    }
    @Override
    public void refreshBookBrief(String url) {
        WebBookModelImpl.getInstance().getStdroy(url)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SimpleObserver<List<BaBayStoryModel>>() {
                    @Override
                    public void onNext(List<BaBayStoryModel> value) {
                        mView.finishRefreshs(value);
                        mView.complete();
                    }

                    @Override
                    public void onError(Throwable e) {
                        e.printStackTrace();
                        mView.showError();

                    }
                });


    }
}
